﻿import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtCharts 2.3
import "qrc:/qmlComponents/CustomizedUIElement"
import "qrc:/qmlComponents/ConfigManager"
import "../AA"
import "../Workers/PickArmModule"
import "../Workers/AAModule"

MySwipeTabView {
    indent: 1
    Component{
        id: produceDataCom
        Item {
            id: root
            property int tableMaxWidth: 400
            property int tableMaxHeight: 250
            property int cellMaxSize: 30

            x: 20
            y: 20

            RowLayout{
                spacing: 30

                DataStatistics{
                    Layout.alignment: Qt.AlignTop
                }
                TrayMapView{
                    Layout.alignment: Qt.AlignTop
                }
            }
        }
    }

    Component{
        id: trayCom

        Item{
            RowLayout{
                spacing: 40

                ObjectEditor{
                    Layout.alignment: Qt.AlignTop
                    sectionName: qsTr("SensorTray")
                    configModel: sensorTrayConfig
                    Component.onCompleted: {
                        init()
                    }
                }
                ObjectEditor{
                    Layout.alignment: Qt.AlignTop
                    sectionName: qsTr("LensTray")
                    configModel: lensTrayConfig
                    Component.onCompleted: {
                        init()
                    }
                }
                ObjectEditor{
                    Layout.alignment: Qt.AlignTop
                    sectionName: qsTr("RejectTray")
                    configModel: rejectTrayConfig
                    Component.onCompleted: {
                        init()
                    }
                }
            }
        }
    }

    Component{
        id: aaCoreDataCom
        Item {
            property int tableMaxWidth: 400
            property int tableMaxHeight: 250
            property int cellMaxSize: 30

            x: 20
            y: 20

            RowLayout{
                spacing: 30
                AACoreView{}
            }
        }
    }

    Component{
        id:pickArmModule

        PickArmModule{}
    }

    Component{
        id: aaHeadModule
        AAModule{}
    }

    Timer{
        id: timer
        repeat: false
        interval: 500
        onTriggered: {
            tabBar.currentIndex = 0
        }
    }

    Component.onCompleted: {
        addTab("ProduceData", produceDataCom)
        addTab("Tray", trayCom)
        addTab("AACore", aaCoreDataCom)
        addTab("PickArm", pickArmModule)
        addTab("AAHead", aaHeadModule)

        tabBar.currentIndex = count - 1
        timer.start()
    }

}
